package com.wanmait.houlang.controller;

import com.wanmait.houlang.util.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

@RestControllerAdvice
public class CommonControllerAdvice {

    @ExceptionHandler(Exception.class)
    public Result processException(Exception e){
        System.out.println("出错了................"+e);
       return  Result.error(e.getMessage());
    }
    //异常处理
    @ExceptionHandler({MaxUploadSizeExceededException.class})
    public Result processSizeExceedeException(MaxUploadSizeExceededException e){
        return Result.fail("图片上传失败，最大不能超过"+e.getMaxUploadSize());
    }
}
